package edu.guet.server.controller;

import edu.guet.server.model.UnitTest;
import edu.guet.server.model.dto.StuUnitTest;
import edu.guet.server.service.UnitTestService;
import edu.guet.server.utils.ResultAPI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/unitTest")
public class UnitTestController {
    @Autowired
    UnitTestService unitTestService;

    @PostMapping("/setUnitTest")
    public ResultAPI setUnitTest(@RequestBody StuUnitTest unitTest) {
        return unitTestService.InsertTest(unitTest);
    }

    @RequestMapping("/getUnitTest")
    public ResultAPI getUnitTest() {
        return unitTestService.getUnitTest();
    }

    @RequestMapping("/getUnitTestById")
    public ResultAPI getUnitTestById(@RequestParam int unit_id) {
        return unitTestService.getUnitTestById(unit_id);
    }

    @RequestMapping("/deleteUnitTest")
    public ResultAPI deleteUnitTest(@RequestParam int unit_test_id) {
        return unitTestService.deleteUnitTest(unit_test_id);
    }
    @PutMapping()
    public ResultAPI updateUnitTest(@RequestBody StuUnitTest unitTest) {
        return unitTestService.updateTest(unitTest);
    }
    @GetMapping("/getTest")
    public ResultAPI getTest(@RequestParam Integer unit_test_id) {
        return unitTestService.getTechTest(unit_test_id);
    }
}
